(function(){
	$.fn.extend({
		customAlert: function(options, type, callback) {

			var defaults = {
				obj		: 'Default',
				height 	: 300,
				background	: 'blue'
			};
			var options = $.extend(defaults, options);
			var width;
			var height;
			var func;

			//初始化
			function init()
			{
				//获得可视区域大小
				width = document.documentElement.clientWidth;
				height = document.documentElement.clientHeight;
				//IE特殊待遇
				if (jQuery.browser.msie && 6.0 == jQuery.browser.version)
				{
					width = document.body.offsetWidth;
					height = document.body.offsetHeight;
				}
			}

			//添加层
			function pro()
			{
				//初始化遮罩层
				$wrapper = $('<div id="customAlert"></div>');
				$wrapper.width(width).height(height);
				$wrapper.css({'position':'fixed','z-index':'9999','top':'0','left':'0','background':'white','opacity':'0.5'});
				$dialog = $('<div id="customAlert-dialog"></div>');
				$dialog.width(width).height(options.height);
				$dialog.css({'position':'fixed','z-index':'10000','top':height/2-options.height/2+'px','left':'0','background':options.background});
				$wrapper.appendTo('body');
				//对话框类型
				if (undefined == type || 'text' == type)
				{
					$dialog.append('<div id="customAlert-text">' + options.obj + '</div>');
					$dialog.find('#customAlert-text').css({'text-align':'center','line-height':options.height+'px','color':'#fff'});
				}
				else if ('interface' == type)
				{
					func = callback;
					func();
				}
				$dialog.appendTo('body');
			}

			//内置警告
			function innerAlert()
			{

			}
			
			init();
			pro();

			//绑定窗口变化时间
			$(window).bind('resize', function(){
				//重新初始化
				init();
				//重置层尺寸
				$wrapper.width(width).height(height);
				$dialog.width(width).height(options.height);
				//重置对话框位置
				$dialog.css('top',height/2-options.height/2+'px');
			});

			//清除对话框
			$('#customAlert').click(function(){
				$('#customAlert').remove();
				$('#customAlert-dialog').remove();
				//解除时间绑定
				$(window).unbind('resize');
			});

			/***
			return this.each(function(){
				
			});
			***/

		}
	})
})(jQuery);